;
$.fn.flashAlbum = function() {
	var wrap = $(this);
	var picList = $(".uiPic li");
	var btnList = $(".uiBtn a");
	var i = 0;
	var timer;
	picList.eq(i).siblings().hide();
	btnList.eq(i).addClass("on");
	startGo();
	wrap.hover(stopGo, startGo);
	
	btnList.mouseover(function() { go(btnList.index(this)); });
	
	function go(n) {
	    picList.eq(n).fadeIn("slow").siblings().hide();
	    btnList.eq(n).addClass("on").siblings().removeClass("on");
	}
    function startGo() {
        timer = setInterval(function() { if (i >= 3) i = 0; go(i); i++; }, 3000);
    }
	function stopGo() {
	    clearInterval(timer);
	}
}

$(function() {
	if($(".banner").length){
		$(".banner").flashAlbum();
	}
});

$(document).ready(function(){
	$('.dropdown-menu').hide();
	$('.dropdown-toggle').click(function(){
		$('.dropdown-menu').slideToggle();
		$(this).toggleClass("cerrar");
	});
});	

$(function(){
	$('ul.dropdown-menu li a').click(function(){
		var value = $(this).attr('data');
		var data = $(this).html();
		$('#sousuoleixing').val(value);
		$('#datashowarea').html(data);
		$('.dropdown-menu').hide();
		$(".dropdown-toggle").removeClass("cerrar");
	});
});

$(document).ready(function(){
	if($('.more_text').length){
		$('.more_text').hide();
		$('.more').click(function(){
			$('.more_text').toggle();
			$(this).toggleClass("mup");
		});
	}
});

/*
 * jQuery placeholder, fix for IE6,7,8,9
 * @author JENA
 * @since 20131115.1504
 * @website ishere.cn
 */
var JPlaceHolder = {
    //检测
    _check : function(){
        return 'placeholder' in document.createElement('input');
    },
    //初始化
    init : function(){
        if(!this._check()){
            this.fix();
        }
    },
    //修复
    fix : function(){
        jQuery(':input[placeholder]').each(function(index, element) {
            var self = $(this), txt = self.attr('placeholder');
            self.wrap($('<div></div>').addClass('placeholder-fix').css({position:'relative', zoom:'1', border:'none', background:'none', padding:'none', margin:'none'}));
            var pos = self.position(), h = self.outerHeight(true), paddingleft = self.css('padding-left');
            var holder = $('<span></span>').text(txt).css({position:'absolute', left:pos.left, top:pos.top, height:h, lienHeight:h, paddingLeft:paddingleft, color:'#aaa'}).appendTo(self.parent());
            self.focusin(function(e) {
                holder.hide();
            }).focusout(function(e) {
                if(!self.val()){
                    holder.show();
                }
            });
            holder.click(function(e) {
                holder.hide();
                self.focus();
            });
        });
    }
};
//执行
jQuery(function(){
    //JPlaceHolder.init();   
});

function auto_login(){
	$.ajax({url: rootpath+'/login/autoLogin', async:false, cache: false, type: 'GET'}).done(function(data) {
		$('#login_nav_bar').empty().append(data);
	});
}

function aggrement(){
	$('#protocolIsRead').attr("checked","checked");
	$('#btnSubmit').removeAttr("disabled");
}

function time_left(time){
	var text='';
	try{
		var date=time, now=(new Date()).getTime();ct=parseInt((date-now)/1000);
		if(ct>=31104000){text+=parseInt(ct/31104000)+'年';ct=ct-parseInt(ct/31104000)*31104000;}
		if(ct>=2592000){text+=parseInt(ct/2592000)+'个月';ct=ct-parseInt(ct/2592000)*2592000;}
		if(ct>=86400){text+=parseInt(ct/86400)+'天';ct=ct-parseInt(ct/86400)*86400;}
		if(ct>=3600){text+=parseInt(ct/3600)+'小时';ct=ct-parseInt(ct/3600)*3600;}
		if(ct>=60){text+=parseInt(ct/60)+'分钟';ct=ct-parseInt(ct/60)*60;}
		if(ct>0){text+=ct+'秒';}
		if(ct<=0){text+='已过期';}
	}catch(err){}
	return text;
}
function time_line(time){
	var text='';
	try{
		var date=time, now=(new Date()).getTime();ct=parseInt((now-date)/1000);
		if(ct>=31104000){text+=parseInt(ct/31104000)+'年前';}
		else if(ct>=2592000){text+=parseInt(ct/2592000)+'月前';}
		else if(ct>=86400*2){text+=parseInt(ct/86400)+'天前';}
		else if(ct>=86400){text+='昨天';}
		else if(ct>=3600){text+=parseInt(ct/3600)+'小时前';}
		else if(ct>=60){text+=parseInt(ct/60)+'分钟前';}
		else if(ct>0){text+=ct+'秒前';}
	}catch(err){alert(err)}
	return text;
}
function check_file_type_photo(file_name){
	if(!file_name){return false;}
	var dot_pos=file_name.lastIndexOf('.');
	if(dot_pos<0){return false;}
	var file_ext=file_name.substr(dot_pos+1);
	return (',jpg,jpeg,gif,png,'.indexOf((','+file_ext+',').toLowerCase())>-1);
}
function check_file_type_file(file_name){
	if(!file_name){return false;}
	var dot_pos=file_name.lastIndexOf('.');
	if(dot_pos<0){return false;}
	var file_ext=file_name.substr(dot_pos+1);
	return (',doc,docx,xlsx,xls,zip,rar,7z,gz,txt,'.indexOf((','+file_ext+',').toLowerCase())>-1);
}

